package com.example.secondhandsysapi.Controller;


import com.example.secondhandsysapi.Service.CollectService;
import com.example.secondhandsysapi.Vo.CollectionDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("collect")
public class CollectController {

    @Autowired
    private CollectService collectService;


    @GetMapping("add")
    public Integer addcollect(@RequestParam Integer user_id, @RequestParam Integer goods_id) {
        Integer i = collectService.getCollects(user_id, goods_id);
        return 1;
    }


    //进入页面的时候自动查询
    // http://localhost:8080/collect/query
    @GetMapping("query")
    public List<CollectionDetails> getCollects(@RequestParam Integer user_id) {
        List<CollectionDetails> res = collectService.getCollectionInfo(user_id);
        return res;
    }


    //按照文字进行匹配查询
    // http://localhost:8080/collect/queryByName
    @GetMapping("queryByName")
    public List<CollectionDetails> getCollectsByName(@RequestParam Integer user_id, @RequestParam String goods_name) {
        List<CollectionDetails> res = collectService.getCollectionInfoByName(user_id,goods_name);
        return res;
    }


}
